﻿
@{
    ViewBag.Title = "注册";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="row">

    <div id="tip">
        
    </div>
</div>
<div class="row">
    
</div>

@section scripts
{
    <script>
        $(function() {
            $("#btnSubmit").click(function() {
                    //var f = $("form:first");
                    var n = $("#n").val();
                    var p1 = $("#p1").val();
                    var p2 = $("#p2").val();
                    if (!n) {
                        $("#n").focus();
                        alert("登录名不可以为空");
                        return;
                    }
                    if (!p1) {
                        $("#p1").focus();
                        alert("密码不可以为空");
                        return;
                    }
                    if (!p2) {
                        $("#p2").focus();
                        alert("确认密码不可以为空");
                        return;
                    }

                    if (p1 != p2) {
                        alert("两次密码输入不一致");
                        return;
                    }

                    $.post('/account/regist',{ Name: n, Pwd: p1 },
                        function(res) {
                            if (res.Code === 0) {
                                $("#tip").html("<span>注册成功</span>");
                                location.href = '/user/index/' + res.Data;
                            } else {
                                $("#tip").html("<span>注册失败</span><span>" + res.Msg + "</span>");
                            }
                        } );

                });

        })
    </script>

}
